package com.pcjavanet.util;

import java.text.DecimalFormat;

public class CommonUtil {
	
	private static DecimalFormat df ; 
	
	public static double getPrecision( double inputDigit) {
		double rtv = 0.0d ; 
		if ( df == null ) {
			StringBuffer buf = new StringBuffer() ; 
			buf.append("#.");
			for(int i= 0 ; i< Constant.FLOATING_POINT_PRECISION ; i++ ) {
				buf.append("#");
			}
			df = new DecimalFormat(buf.toString());
		}
		String valStr = df.format( inputDigit );
		try {
			rtv = Double.parseDouble(valStr);
		}catch (Exception e){
			
		}
		return rtv  ; 
	}
	
	public static boolean judgeFamily(String partnumber, String familyname) {
		boolean rtv = false;
		if ((partnumber != null && !partnumber.equals(""))
				&& (familyname != null && !familyname.equals(""))) {// p ok, f
																	// ok
																	// ==>choise
																	// p
			rtv = false;
		} else if ((partnumber == null || partnumber.equals(""))
				&& (familyname != null && !familyname.equals(""))) {// p no, f
																	// ok==> f
			rtv = true;
		} else if ((partnumber != null && !partnumber.equals(""))
				&& (familyname == null || familyname.equals(""))) { // p ok,f no
																	// ==> p
			rtv = false;
		}
		return rtv;
	}

}
